package PrefixSum;

import java.util.Scanner;

//https://www.nowcoder.com/practice/acead2f4c28c401889915da98ecdc6bf?tpId=230&tqId=38960&ru=/exam/oj
public class n_dp_34 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), q = sc.nextInt();
        int[] arr = new int[n + 1];
        //从1开始计数
        for(int i = 1; i <= n; i++) arr[i] = sc.nextInt();

        long[] dp = new long[n + 1];
        for(int i = 1; i <= n; i++) dp[i] = dp[i - 1] + arr[i];

        for(int i = 0; i < q; i++)
        {
            int l = sc.nextInt(), r = sc.nextInt();
            System.out.println(dp[r] - dp[l - 1]);
        }
    }
}
